import {reqHeroList} from "../api";

const state = {
  hero:[],
  heroname:[]
}

const mutations = {
  GETHEROLIST(state,hero){
    state.hero = hero;
  }
}

const actions = {
  async getHeroList({commit}){
    let result = await reqHeroList();
    if (result){
      commit("GETHEROLIST",result)
    }
  }
}

const getters = {
  getHeroName(state){
    state.hero.map((item)=>{
      let gName = []
      gName.push(item.heroName)
      gName.push(item.frequency)
      gName.push(item.pickRatio)
      gName.push(item.winRate)
      state.heroname.push(gName)
    })
    return state.heroname
  },
}

export default {
  state,
  mutations,
  actions,
  getters
}
